from django.db import models


class WeiboNote(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    gender = models.CharField(max_length=12, null=True, blank=True, verbose_name='用户性别')
    profile_url = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户主页地址')
    ip_location = models.CharField(max_length=32, default='发布微博的地理信息', verbose_name='IP地理位置')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    note_id = models.CharField(max_length=64, verbose_name='帖子ID', unique=True)
    content = models.TextField(verbose_name='帖子正文内容')
    create_time = models.BigIntegerField(verbose_name='帖子发布时间戳')
    create_date_time = models.CharField(max_length=32, verbose_name='帖子发布日期时间')
    liked_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='帖子点赞数')
    comments_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='帖子评论数量')
    shared_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='帖子转发数量')
    note_url = models.CharField(max_length=512, null=True, blank=True, verbose_name='帖子详情URL')
    source_keyword = models.CharField(max_length=255, default='', verbose_name='搜索来源关键字')
    task_id = models.CharField(max_length=255, verbose_name='任务ID', null=True, blank=True)

    class Meta:
        db_table = 'weibo_note'
        verbose_name = '微博帖子'
        indexes = [
            models.Index(fields=['note_id'], name='idx_weibo_note_note_id_f95b1a'),
            models.Index(fields=['create_time'], name='idx_weibo_note_create__692709'),
            models.Index(fields=['create_date_time'], name='idx_weibo_note_create__d05ed2'),
        ]


class WeiboNoteComment(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    gender = models.CharField(max_length=12, null=True, blank=True, verbose_name='用户性别')
    profile_url = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户主页地址')
    ip_location = models.CharField(max_length=32, default='发布微博的地理信息', verbose_name='IP地理位置')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    comment_id = models.CharField(max_length=64, verbose_name='评论ID')
    note_id = models.ForeignKey(
        WeiboNote,
        to_field='note_id',
        db_column='note_id',
        on_delete=models.CASCADE,
        related_name='comments',
        verbose_name='帖子关联',
        null=True,
        blank=True,
    )
    content = models.TextField(verbose_name='评论内容')
    create_time = models.BigIntegerField(verbose_name='评论时间戳')
    create_date_time = models.CharField(max_length=32, verbose_name='评论日期时间')
    sub_comment_count = models.CharField(max_length=16, verbose_name='评论回复数')
    parent_comment_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='父评论ID')
    like_count = models.IntegerField(default=0, verbose_name='点赞数')

    class Meta:
        db_table = 'weibo_note_comment'
        verbose_name = '微博帖子评论'
        indexes = [
            models.Index(fields=['comment_id'], name='idx_weibo_note__comment_c7611c'),
            models.Index(fields=['note_id'], name='idx_weibo_note__note_id_24f108'),
            models.Index(fields=['create_date_time'], name='idx_weibo_note__create__667fe3'),
        ]


class WeiboCreator(models.Model):
    user_id = models.CharField(max_length=64, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    ip_location = models.CharField(max_length=255, null=True, blank=True, verbose_name='评论时的IP地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    desc = models.TextField(verbose_name='用户描述')
    gender = models.CharField(max_length=2, null=True, blank=True, verbose_name='性别')
    follows = models.CharField(max_length=16, null=True, blank=True, verbose_name='关注数')
    fans = models.CharField(max_length=16, null=True, blank=True, verbose_name='粉丝数')
    tag_list = models.TextField(verbose_name='标签列表')
    task_id = models.CharField(max_length=255, verbose_name='任务ID', null=True, blank=True)

    class Meta:
        db_table = 'weibo_creator'
        verbose_name = '微博博主'